function A0_coef = TVB_limiter(A0_coef,k,h,N,b_fun, basis)
New_A0_coef = zeros(size(A0_coef));
uh_onetilde = zeros(1,N);
uh_twotilde = zeros(1,N);
basis_value = zeros(k+1,2);
for l = 1 : k+1
    basis_value(l,1) = b_fun{l}(-1);
    basis_value(l,2) = b_fun{l}(1);
end
if k == 1
    M = zeros(k+1,k+1);
    for l = 1 : k+1
        M(1,l) = b_fun{l}(-1);
        M(2,l) = b_fun{l}(1);
    end
else
    M = zeros(k+1,k+1);
    for l = 1: k+1
        M(1,l) = b_fun{l}(-1);
        M(2,l) = b_fun{l}(1);
        M(3,l) = (1/2)*quadgk(b_fun{l},-1,1);
    end
end
uh_aver = get_average(A0_coef,basis,N);
for i = 1 : N
    u_now_right = (A0_coef(:,i))'*basis_value(:,2);
    u_now_left = (A0_coef(:,i))'*basis_value(:,1);
    uh_onetilde(i) = u_now_right - uh_aver(i);
    uh_twotilde(i) = uh_aver(i) - u_now_left;
end
for i = 1 :N
    if i == 1
        q = N;
    else
        q = i-1;
    end
    if i == N
        p = 1;
    else
        p = i+1;
    end
    uh_onetilde(i) = minimod_tilde(uh_onetilde(i),uh_aver(p)-uh_aver(i),uh_aver(i)-uh_aver(q),h);
    uh_twotilde(i) = minimod_tilde(uh_twotilde(i),uh_aver(p)-uh_aver(i),uh_aver(i)-uh_aver(q),h);
    u_right = uh_aver(i) + uh_onetilde(i);
    u_left = uh_aver(i) - uh_twotilde(i);
    if k == 1
        b = [u_left;u_right];
        New_A0_coef(:,i) = M\b;
    elseif k==2
        b = [u_left;u_right;uh_aver(i)];
        New_A0_coef(:,i) = M\b;
    end
end
A0_coef = New_A0_coef;
end